<?php 

Class ModuleForgetPasswordResult extends CmsModule {
	private $dataHtml;
    public function __renderHead(){
		$filters = array('dateby', 'year', 'month', 'day');
		foreach($_GET as $k=>$v){
			if(in_array($k, $filters)){
				$$k = $v;
			}
		}
		$curr_datetime = date("Y-m-d H:i:s");
		$str_date=array();
		if ($year) {
			$str_date[] = $year;
		}
		if ($dateby !='month' && $month) {
			$str_date[] = $month;
		}
		if ($dateby == 'hour' && $day) {
			$str_date[] = $day;
		}
		$str_date = implode('-', $str_date);
		
		$html = '';
		if ($dateby == 'month') {
			$html = $this->getMonthHtml($year);
		}elseif ($dateby == 'date') {
			$html = $this->getDateHtml($year,$month);
		}elseif ($dateby == 'hour') {
			$html = $this->getDayHtml($year,$month, $day);
		}
		
		$dateby = ucwords( strtolower($dateby));
		$this->contents = <<<HTML
	<div id="result" class="forget_password_result">
		<div class="hd">
			<div class="utility">
				<a href="#" class="print">Print</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				Export to <a href="#">HTML</a>
			</div>
			<hr />
			<h1>Forget Password Report</h1>
			<div class="time">{$curr_datetime}</div><br />
			<div><b>By {$dateby}:</b> {$str_date}</div>
		</div>
		<div class="bd">
		<br />
		<center>{$this->dataHtml}</center>
		<br />
<table width="100%">
{$html}
</table>
		</div>
	</div>
HTML;
    }
	private function getMonthHtml($year){
		$datas = array();
		$labels = array();
		$captures = array('人數');
		$html = '<tr class="weight" bgcolor="#CCC"><td>月份</td><td>人數</td></tr>';
		for ($i =0; $i<12; $i++){
			$mdata = array(rand(100,9999));
			$labels[] = ($i+1).'月';
			$datas[] = $mdata;
			$html .= '<tr><td>'.($i+1).'月</td><td>'.$mdata[0].'</td></tr>';
		}
		$html .= '<tr class="weight"><td>Average</td><td>'.rand(100,9999).'</td></tr>';
		$html .= '<tr class="weight"><td>Total</td><td>'.rand(100,9999).'</td></tr>';
		
		$labels = json_encode($labels);
		$captures = json_encode($captures);
		$datas = json_encode($datas);
		$this->dataHtml = "<input type='hidden' class='columns' labels='{$labels}' captures='{$captures}' datas='{$datas}' title='Login And Logout Report By Month' />";
		return $html;
	}
	private function getDateHtml($year,$month){
		$datas = array();
		$labels = array();
		$captures = array('人數');
		$html = '<tr class="weight" bgcolor="#CCC"><td>天</td><td>人數</td></tr>';
		for ($i =0; $i<31; $i++){
			$mdata = array(rand(100,9999));
			$labels[] = ($i+1).'日';
			$datas[] = $mdata;
			$html .= '<tr><td>'.$month.'月'.($i+1).'日</td><td>'.rand(100,9999).'</td></tr>';
		}
		$html .= '<tr class="weight"><td>Average</td><td>'.rand(100,9999).'</td></tr>';
		$html .= '<tr class="weight"><td>Total</td><td>'.rand(100,9999).'</td></tr>';
		
		$labels = json_encode($labels);
		$captures = json_encode($captures);
		$datas = json_encode($datas);
		$this->dataHtml = "<input type='hidden' class='columns' labels='{$labels}' captures='{$captures}' datas='{$datas}' title='Login And Logout Report By Date' />";
		return $html;
	}
	private function getDayHtml($year,$month, $day){
		$datas = array();
		$labels = array();
		$captures = array('人數');
		$html = '<tr class="weight" bgcolor="#CCCCCC"><td>'.$year.'年'.$month.'月'.$day.'日</td><td>人數</td></tr>';
		for ($i =0; $i<24; $i++){
			$mdata = array(rand(100,9999));
			$labels[] = ($i+1).'時';
			$datas[] = $mdata;
			$html .= '<tr><td>'.($i).'</td><td>'.rand(100,9999).'</td></tr>';
		}
		$html .= '<tr class="weight"><td>Average</td><td>'.rand(100,9999).'</td></tr>';
		$html .= '<tr class="weight"><td>Total</td><td>'.rand(100,9999).'</td></tr>';
		
		$labels = json_encode($labels);
		$captures = json_encode($captures);
		$datas = json_encode($datas);
		$this->dataHtml = "<input type='hidden' class='columns' labels='{$labels}' captures='{$captures}' datas='{$datas}' title='Login And Logout Report By Month' />";
		return $html;
	}
}
?>